package com.maker.mcp.client.controller;


import cn.hutool.http.server.HttpServerResponse;
import com.maker.mcp.client.service.ChatService;
import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.nio.charset.Charset;

@RestController
@RequestMapping("test")
public class HelloWordController {
    @Resource
    private ChatService chatService;
    @GetMapping("/hello")
    public String helloWord(){
        return "hello word";
    }
    @GetMapping("/chat")
    public String chat(String message){
      return   chatService.chatTest(message);
    }

    @GetMapping(value="/stream",produces =  "text/html;charset=UTF-8")
    public Flux<ChatResponse> streamChat(String message){
      return   chatService.streamChat(message);
    }
    @GetMapping(value ="/streamstr",produces =  "text/html;charset=UTF-8")
    public Flux<String> streamStrChat(String message){
        return   chatService.streamStrChat(message);
    }

}
